﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PointTracker
{
    [Flags]
    public enum days
    {
        Sunday = 1,
        Monday = 2,
        Tuesday = 4,
        Wednesday = 8,
        Thursday = 16,
        Friday = 32,
        Saturday = 64
    }
    public class Class
    {
        private int _crn = 0;
        private string _name = "";
        private PointTracker.days _days;
        private int _term = 0;
        private int _year = 0;

        public Class(int crnIn, string nameIn, PointTracker.days daysIn, int termIn, int yearIn)
        {
            _crn = crnIn;
            _name = nameIn;
            _days = daysIn;
            _term = termIn;
            _year = yearIn;
        }

        public int crn
        {
            get { return _crn; }
            set { _crn = value; }
        }
        public string name
        {
            get { return _name; }
            set { _name = value; }
        }
        public PointTracker.days days
        {
            get { return _days; }
            set { _days = value; }
        }
        public int term
        {
            get { return _term; }
            set { _term = value; }
        }
        public int year
        {
            get { return _year; }
            set { _year = value; }
        }

        public static List<Class> getClasses(string email)
        {
            List<List<string>> clazzes = DatabaseManager.getClasses(email);
            List<Class> classes = new List<Class>();
            foreach (List<string> clazz in clazzes)
            {
                int crn = Int32.Parse(clazz[0]);
                string name = clazz[1];
                days deyz = (days)Int32.Parse(clazz[2]);
                int term = Int32.Parse(clazz[3]);
                int year = Int32.Parse(clazz[4]);
                classes.Add(new Class(crn, name, deyz, term, year)); 
            }

            return classes;

        }

    }
}
